package hn.cch.spring.core.bean;


import hn.cch.spring.core.annotation.component.BeanImplement0;
import hn.cch.spring.core.annotation.component.BeanImplement1;
import hn.cch.spring.core.annotation.component.BeanInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

@Component
public class BeanComponent {

    private static final Logger logger = LoggerFactory.getLogger(BeanComponent.class);


    @Autowired
    private BeanImplement0 beanImplement0;

    private BeanInterface beanInterface;

    @Resource(name = "beanImplement1")
    public void setBeanInterface(BeanImplement1 beanImplement1){
        logger.info("Resource:{}", beanImplement1);
        this.beanInterface = beanImplement1;
    }

    private BeanDependencies beanDependencies;

    @Autowired
    public void setBeanDependencies(BeanDependencies beanDependencies){
        logger.info("Autowired:{}", beanDependencies);
        this.beanDependencies = beanDependencies;
    }



    @Autowired
    public void setJavaHome(@Value("${JAVA_HOME}") String javaHome) {
        logger.info("Value:{}", javaHome);
    }

    public BeanComponent() {
        logger.info("BeanObject");
    }

    @PostConstruct
    public void postConstruct() {
        logger.info("postConstruct");
    }

    @PreDestroy
    public void preDestroy() {
        logger.info("preDestroy");
    }

    public BeanImplement0 getBeanImplement0() {
        return beanImplement0;
    }

    public BeanInterface getBeanInterface() {
        return beanInterface;
    }

    public BeanDependencies getBeanDependency() {
        return beanDependencies;
    }
}
